{template 'common/header'}

<ul class="nav nav-tabs">
	<li {if $operation == 'add'}class="active"{/if}><a href="{php echo $this->createWebUrl('admin', array('op' => 'add'))}">添加题目</a></li>
	<li {if $operation == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('admin', array('op' => 'display'))}">管理题目</a></li>
</ul>
<script>
	require(['bootstrap'],function($){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
</script>
{if $operation == 'add'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" id="form1">
		<div class="panel panel-default">
			<div class="panel-heading">
				添加题目
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>问题</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="questionq" class="form-control" value="{$questiones['question']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>答案</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="rightan" class="form-control" value="{$questiones['right']}" />
					</div>
				</div>				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否有效</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='state' value=1' {if $questiones['state']==1}checked{/if} /> 是
						</label>
						<label class='radio-inline'>
							<input type='radio' name='state' value=0' {if $questiones['state']==0}checked{/if} /> 否
						</label>
					</div>
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>

{elseif $operation == 'display'}
<div class="main">
	<div class="category">
		<form action="" method="post" onsubmit="return formcheck(this)">
			<div class="panel panel-default">
				<div class="panel-body table-responsive">
					<table class="table table-hover">
						<thead>
							<tr>
								<th style="width:30px;">id</th>
								<th style="width:200px;">题目</th>
								<th style="width:100px;">答案</th>
								<th style="width:60px;">添加时间</th>
								<th style="width:50px;">状态</th>
								<th style="width:60px;">操作</th>							
							</tr>
						</thead>
						<tbody>
						{loop $questiones $item}
						<tr>
							<td>{$item['id']}</td>
							<td>{$item['question']}</td>
							<td>{$item['right']}</td>
							<td>{php echo date("m-d H:i",$item['time'])}</td>
							<td>
								{if $item['state']==1}
								<span class='label label-success'>有效</span>
								{else}
								<span class='label label-danger'>无效</span>
								{/if}
							</td>
							<td>
								<a href="{php echo $this->createWebUrl('admin', array('op' => 'edit', 'id' => $item['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" title="编辑"><i class="fa fa-edit"></i></a>&nbsp;&nbsp;
								<a href="{php echo $this->createWebUrl('admin', array('op' => 'delete', 'id' => $item['id']))}" onclick="return confirm('确认删除此题目吗？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" title="删除"><i class="fa fa-times"></i></a>
							</td>
						</tr>
						{/loop}

						</tbody>
					</table>
				</div>
			</div>
		</form>
		{$pager}
	</div>
</div>
{elseif $operation == 'edit'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" id="form1">
		<div class="panel panel-default">
			<div class="panel-heading">
				添加题目
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>问题</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="questionq" class="form-control" value="{$questiones['questionq']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>答案</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="rightan" class="form-control" value="{$questiones['rightan']}" />
					</div>
				</div>				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否有效</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='state' value=1' {if $questiones['state']==1}checked{/if} /> 是
						</label>
						<label class='radio-inline'>
							<input type='radio' name='state' value=0' {if $questiones['state']==0}checked{/if} /> 否
						</label>
					</div>
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>

{/if}


{template 'common/footer'}